package cn.wolfcode.wolf2w.service.impl;


import cn.wolfcode.wolf2w.domain.UserIdFavors;
import cn.wolfcode.wolf2w.repository.UserIdFavorsRepository;
import cn.wolfcode.wolf2w.service.IUserIdFavorsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class UserIdFavorsServiceImpl implements IUserIdFavorsService {
    @Autowired
    private UserIdFavorsRepository userIdFavorsRepository;


    @Override
    public void insert(UserIdFavors userIdFavors) {
        userIdFavorsRepository.save(userIdFavors);
    }

    @Override
    public void delete(String id) {
        userIdFavorsRepository.deleteById(id);
    }

    @Override
    public void update(UserIdFavors userIdFavors) {
        userIdFavorsRepository.save(userIdFavors);
    }

    @Override
    public UserIdFavors findById(String id) {
        Optional<UserIdFavors> userIdFavors = userIdFavorsRepository.findById(id);
        return userIdFavors.orElse(null);
    }

    @Override
    public List<UserIdFavors> findAll() {
        List<UserIdFavors> all = userIdFavorsRepository.findAll();
        return all;
    }

    @Override
    public UserIdFavors findByUsid(String uid) {
        UserIdFavors userIdFavors = userIdFavorsRepository.findByUsid(uid);
        return userIdFavors;
    }


}
